# +----------------------------------------------------------------------
# | ChatWork智能聊天办公系统
# +----------------------------------------------------------------------
# | 软件声明: 本系统并非自由软件,未经授权任何形式的商业使用均属非法。
# | 版权保护: 任何企业和个人不允许对程序代码以任何形式任何目的复制/分发。
# | 授权要求: 如有商业使用需求,请务必先与版权所有者取得联系并获得正式授权。
# +----------------------------------------------------------------------
# | Author: ChatWork Team <2474369941@qq.com>
# +----------------------------------------------------------------------
from typing import Union
from fastapi import Query
from pydantic import BaseModel, Field


class DrawsRecordSearchIn(BaseModel):
    """ 绘画记录搜索参数 """
    page_no: int = Query(default=1, gt=0, description="当前页码")
    page_size: int = Query(default=15, gt=0, le=200, description="每页条数")
    engine: str = Query(..., pattern=r"^(mj|sd|dalle|doubao)$", description="绘图引擎")
    type: Union[str, None] = Query(default=None, description="绘图类型: [text2img,img2img,upscale2img,variation2img]")
    user_sn: Union[str, None] = Query(default=None, description="用户编号")
    status: Union[int, str, None] = Query(default=None, description="生成状态: [0=等待中,1=执行中,2=成功,3=失败]")
    start_time: Union[str, None] = Query(default=None, description="开始时间")
    end_time: Union[str, None] = Query(default=None, description="结束时间")


class DrawsRecordDeleteIn(BaseModel):
    """ 绘画记录删除参数 """
    id: int = Field(..., gt=0, description="ID")
    engine: str = Field(..., pattern=r"^(mj|sd|dalle|doubao)$", description="绘图引擎")
    reason: str = Field(default="", description="原因描述")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "engine": "mj",
                "reason": "原因描述"
            }
        }


"""--------------- Separator ---------------"""


class DrawsRecordVo(BaseModel):
    """ 绘画记录列表Vo """
    id: int = Field(description="ID")
    code: str = Field(description="绘图编号")
    type: str = Field(description="绘图类型: [text2image, image2image, upscale2img, variation2img]")
    action: str = Field(description="绘图动作: [generate, upsample?, variation?]")
    scale: str = Field(description="图片比例")
    prompt_in: str = Field(description="输入提示词")
    prompt_en: str = Field(description="英文提示词")
    prompt_eq: str = Field(description="完整提示词")
    image_url: str = Field(description="外部图片")
    image_loc: str = Field(description="本地图片")
    image_ref: str = Field(description="参考图片")
    thumbnail: str = Field(description="缩略图")
    fail_reason: str = Field(description="失败原因")
    points: int = Field(description="消耗积分")
    status: int = Field(description="生成状态: [0=等待中, 1=执行中, 2=成功, 3=失败]")
    is_free: int = Field(description="会员免费: [0=否, 1=是]")
    create_time: str = Field(description="创建时间")
    user: dict = Field(description="用户信息")

    class Config:
        json_schema_extra = {
            "example": {
                "id": 1,
                "code": "6508de544a71436615dc570b15c50cbc",
                "type": "text2img",
                "action": "generate",
                "scale": "1:1",
                "prompt_in": "可爱的小猫",
                "prompt_en": "",
                "prompt_eq": "可爱的小猫 --ar 1:1 --no None --seed -1 --iw 1.0 --q 1.0 --s 100",
                "image_ref": "",
                "thumbnail": "https://www.xx.cn/storage/drawing/thumbnail/20250314/7cc9ece.png",
                "image_loc": "https://www.xx.cn/storage/drawing/albums/20250314/7cc9ece.png",
                "image_url": "https://platform.cdn.zhishuyun.com/midjourney/644d304.png",
                "fail_reason": "No processing channel mj",
                "points": 5,
                "status": 2,
                "is_free": 0,
                "create_time": "2025-03-14 13:53:34",
                "user": {
                    "sn": "52778960",
                    "nickname": "罗非鱼",
                    "mobile": "13800138000",
                    "avatar": "http://0.0.0.0:8100/static/images/default_avatar.png"
                }
            }
        }
